import time
import numpy as np

def fib(n):
    a, b, i = 0, 1, 1
    while i < n:
        a, b = b, a + b
        i += 1
    return b

def main():

    fib_range = list(range(1, 35))
    times = []
    for run in range(10):
        start = time.time()
        for n in fib_range:
           fib(n)
        end = time.time()
        times.append(end-start)
    print(fib(100))
    print('波那契数列fib(35)计算平均耗时 {:.3f}。'.format(np.mean(times)))

if __name__ == '__main__':
    main()

